#pragma once
#include "base/net/i_session.h"

enum CloseFlag 
{
	FLAG_ERROR       = 1,
	FLAG_TIMEOUT     = 2,
	FLAG_PEER_CLOSE  = 3,
	FLAG_PACKAGE_ERR = 4,
};

// return
// > 0 : one package complete
// ==0 : no one package
// < 0 : data error, should directly close session by yourself
typedef int (*Subpackage)(const char* data, int len);

class ICallback 
{
public:
    ICallback() {}
    virtual ~ICallback() {}

public:
    virtual bool OnConnect(ISession* session, void* req, void* context, bool success) = 0;
    virtual bool OnAccept(ISession* session, void* req, void* context) = 0;
    virtual bool OnClose(ISession* session, CloseFlag flag) = 0;
    virtual bool OnRecv(const char* data, int len, ISession* session, uint64_t time_ms) = 0;
};